/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package seGobangClient;

import config.Configuration;

/**
 *
 * @author plus
 */
public class Rule {
    public int TimeLimit;
    public int RegretTimes;
    public boolean forbids;
    private Configuration conf;
    public void setDefault(){
        TimeLimit=300;
        RegretTimes=10;
        forbids=true;
    }

    public Rule() {
        setDefault();
    }
        
    public Rule(int timeLimit, int regretTimesLimit, boolean isForbid, boolean isExchange){
        TimeLimit=timeLimit;
        RegretTimes=regretTimesLimit;
        forbids=isForbid;
        conf=new Configuration();
    }
    
    public void LoadFromXML(){
        Configuration config=new Configuration();
        this.TimeLimit=Integer.parseInt(config.getData("TimeLimit"));
        this.RegretTimes=Integer.parseInt(config.getData("RegretTimes"));
        int ifForbids=Integer.parseInt(config.getData("forbids"));
        if(ifForbids==0)
            this.forbids=false;
        else
            this.forbids=true;
    }

    public void SaveToXML(){
        Configuration config=new Configuration();
        config.setData("TimeLimit", TimeLimit+"");
        config.setData("RegretTimes", RegretTimes+"");
        if(forbids)
            config.setData("forbids", "1");
        else
            config.setData("forbids", "0");

    }
}
